/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package modelo;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author MANUEL
 */
@Entity
@Table(name = "ROLES")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Roles.findAll", query = "SELECT r FROM Roles r"),
    @NamedQuery(name = "Roles.findByNumRol", query = "SELECT r FROM Roles r WHERE r.numRol = :numRol"),
    @NamedQuery(name = "Roles.findByRol", query = "SELECT r FROM Roles r WHERE r.rol = :rol")})
public class Roles implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "NUM_ROL")
    private Integer numRol;
    @Column(name = "ROL")
    private String rol;
    @OneToMany(mappedBy = "rolNumRol")
    private Collection<PersonaAtencion> personaAtencionCollection;
    @OneToMany(mappedBy = "rolNumRol")
    private Collection<Usuario> usuarioCollection;

    public Roles() {
    }

    public Roles(Integer numRol) {
        this.numRol = numRol;
    }

    public Integer getNumRol() {
        return numRol;
    }

    public void setNumRol(Integer numRol) {
        this.numRol = numRol;
    }

    public String getRol() {
        return rol;
    }

    public void setRol(String rol) {
        this.rol = rol;
    }

    @XmlTransient
    public Collection<PersonaAtencion> getPersonaAtencionCollection() {
        return personaAtencionCollection;
    }

    public void setPersonaAtencionCollection(Collection<PersonaAtencion> personaAtencionCollection) {
        this.personaAtencionCollection = personaAtencionCollection;
    }

    @XmlTransient
    public Collection<Usuario> getUsuarioCollection() {
        return usuarioCollection;
    }

    public void setUsuarioCollection(Collection<Usuario> usuarioCollection) {
        this.usuarioCollection = usuarioCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (numRol != null ? numRol.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Roles)) {
            return false;
        }
        Roles other = (Roles) object;
        if ((this.numRol == null && other.numRol != null) || (this.numRol != null && !this.numRol.equals(other.numRol))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Roles[ numRol=" + numRol + " ]";
    }
    
}
